package crp.services.api.graphql.models;

import com.qwlabs.security.Caller;
import crp.core.analysis.domain.commands.CreateViewFlowCommand;
import crp.core.analysis.domain.models.ViewTargetType;
import crp.core.security.Callers;
import lombok.Getter;
import lombok.Setter;
import org.eclipse.microprofile.graphql.Input;

import javax.validation.constraints.NotNull;

@Input("CreateViewFlowInput")
@Getter
@Setter
public class CreateViewFlowInput {
    @NotNull
    private ViewTargetType targetType;
    @NotNull
    private String targetId;
    @NotNull
    private String userAgent;

    private String ip;

    public CreateViewFlowCommand createCommand(Caller caller) {
        return new CreateViewFlowCommand(this.targetType, this.targetId, Callers.userId(caller), this.ip, userAgent);
    }
}
